<script setup>
import { ref } from 'vue';
import useStore from '../store';
const { todos } = useStore()

const name = ref('')
const add = () => {
  if (name.value) {
    todos.add(name.value)
    name.value = ''
  }
}
</script>

<template>
  <header class="header">
    <h1>todos</h1>
    <input class="new-todo" placeholder="What needs to be done?" autofocus v-model.trim="name" @keydown.enter="add" />
  </header>
</template>

<style lang="less" scoped>
</style>
